import { useEffect, useState } from 'react'
import st from './action.module.css'
import api from '../../api/request'
const ActionSheet = (prop: any) => {
    const { visable, onSelect, onCancel } = prop
    const [data, setData] = useState([])
    useEffect(() => {
        api.get("/me-api/grocery-store")
            .then((res) => {
                setData(res.data)
            })
    }, [])
    if (!visable) return null
    return (<div className={st.cover} onClick={() => onCancel()}>
        <div className={st.actions}>
            {data.map((item: any) => <p key={item.id} className={st.item} onClick={() => onSelect(item.storename)}>{item.storename}</p>)}
        </div>
    </div>)
}
export default ActionSheet